		<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <ext:ResourceManager ID="ResourceManagerProxy1" runat="server">
    </ext:ResourceManager>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Viewport ID="ViewPort1" runat="server" Layout="fit">
        <Items>
            <ext:FormPanel ID="pnlAddProduct" runat="server" Title="新增商品表信息" Frame="True"  Layout="VBoxLayout" AutoScroll="True">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
                <Items>
										                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtId" runat="server" FieldLabel="主键" AllowBlank="False" BlankText="请输入主键！"   Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtName" runat="server" FieldLabel="名称"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtCode" runat="server" FieldLabel="编号"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtDesciption" runat="server" FieldLabel="描述"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtPrice" runat="server" FieldLabel="价格"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtStock" runat="server" FieldLabel="库存"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtDiscontinute" runat="server" FieldLabel="Discontinute"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
                       <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtSaleCount" runat="server" FieldLabel="销量"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>

                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="保存"  Icon="Accept">
                        <DirectEvents>
                            <Click Before="if(!#{pnlAddProduct}.getForm().isValid()) return false;" OnEvent="btnAddProduct_Click"
                                Success="#{pnlAddProduct}.getForm().reset();parent.ShowMessage('操作成功','添加商品表成功！',1);parent.RefreshProductData();parent.CloseAddProduct(); "
                                 Failure="Ext.Msg.alert('操作失败', result.errorMessage);">
                                <EventMask ShowMask="true" Msg="数据保存中,请稍等....." />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button runat="server" Text="取消" Icon="Decline">
                        <Listeners>
                            <Click Handler="parent.CloseAddProduct();"></Click>
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
    </ext:Viewport>
</asp:Content>

	    protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest)
                return;
 
        }

        protected void btnEditProduct_Click(object sender, DirectEventArgs e)
        {
            try
            {
                Product newProduct = new Product();

                
										   newProduct.Id = this.txtId.Text.Trim();
   newProduct.Name = this.txtName.Text.Trim();
   newProduct.Code = this.txtCode.Text.Trim();
   newProduct.Desciption = this.txtDesciption.Text.Trim();
   newProduct.Price = this.txtPrice.Text.Trim();
   newProduct.Stock = this.txtStock.Text.Trim();
   newProduct.Discontinute = this.txtDiscontinute.Text.Trim();
   newProduct.SaleCount = this.txtSaleCount.Text.Trim();



                Global.CurrentServiceContainer.ProductServiceProxy.Insert(newProduct);
 
                ResourceManager.AjaxSuccess = true;
 
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess = false;
                ResourceManager.AjaxErrorMessage = "Error Message:" + ex.Message;
            }

        } 
			
